﻿Imports System
Imports System.Globalization

Namespace System.Workflow.Activities.Rules
    Friend Class ULongArithmeticLiteral
        Inherits ArithmeticLiteral
        ' Methods
        Friend Sub New(ByVal literalValue As UInt64)
            Me.m_value = literalValue
            MyBase.m_type = GetType(UInt64)
        End Sub

        Friend Overrides Function Add() As Object
            Return Nothing
        End Function

        Friend Overrides Function Add(ByVal v As Char) As Object
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As Decimal) As Object
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As Double) As Object
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As Integer) As Object
            If (v < 0) Then
                Return MyBase.Add(v)
            End If
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As Long) As Object
            If (v < 0) Then
                Return MyBase.Add(v)
            End If
            Return ([CULng](v) + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As Single) As Object
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As String) As Object
            Return (v & Me.m_value.ToString(CultureInfo.CurrentCulture))
        End Function

        Friend Overrides Function Add(ByVal v As UInt16) As Object
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As UInt32) As Object
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As UInt64) As Object
            Return (v + Me.m_value)
        End Function

        Friend Overrides Function Add(ByVal v As ArithmeticLiteral) As Object
            Return v.Add(Me.m_value)
        End Function

        Friend Overrides Function BitAnd() As Object
            Return Nothing
        End Function

        Friend Overrides Function BitAnd(ByVal v As Integer) As Object
            If (v < 0) Then
                Return MyBase.BitAnd(v)
            End If
            Return (v And Me.m_value)
        End Function

        Friend Overrides Function BitAnd(ByVal v As Long) As Object
            If (v < 0) Then
                Return MyBase.BitAnd(v)
            End If
            Return ([CULng](v) And Me.m_value)
        End Function

        Friend Overrides Function BitAnd(ByVal v As UInt16) As Object
            Return (v And Me.m_value)
        End Function

        Friend Overrides Function BitAnd(ByVal v As UInt32) As Object
            Return (v And Me.m_value)
        End Function

        Friend Overrides Function BitAnd(ByVal v As UInt64) As Object
            Return (v And Me.m_value)
        End Function

        Friend Overrides Function BitAnd(ByVal v As ArithmeticLiteral) As Object
            Return v.BitAnd(Me.m_value)
        End Function

        Friend Overrides Function BitOr() As Object
            Return Nothing
        End Function

        Friend Overrides Function BitOr(ByVal v As Integer) As Object
            Dim num As Long = v
            If (num < 0) Then
                Return MyBase.BitOr(v)
            End If
            Return ([CULng](num) Or Me.m_value)
        End Function

        Friend Overrides Function BitOr(ByVal v As Long) As Object
            If (v < 0) Then
                Return MyBase.BitOr(v)
            End If
            Return ([CULng](v) Or Me.m_value)
        End Function

        Friend Overrides Function BitOr(ByVal v As UInt16) As Object
            Return (v Or Me.m_value)
        End Function

        Friend Overrides Function BitOr(ByVal v As UInt32) As Object
            Return (v Or Me.m_value)
        End Function

        Friend Overrides Function BitOr(ByVal v As UInt64) As Object
            Return (v Or Me.m_value)
        End Function

        Friend Overrides Function BitOr(ByVal v As ArithmeticLiteral) As Object
            Return v.BitOr(Me.m_value)
        End Function

        Friend Overrides Function Divide() As Object
            Return Nothing
        End Function

        Friend Overrides Function Divide(ByVal v As Decimal) As Object
            Return (v / Me.m_value)
        End Function

        Friend Overrides Function Divide(ByVal v As Double) As Object
            Return (v / CDbl(Me.m_value))
        End Function

        Friend Overrides Function Divide(ByVal v As Integer) As Object
            If (v < 0) Then
                Return MyBase.Divide(v)
            End If
            Return (CLng(v) / Me.m_value)
        End Function

        Friend Overrides Function Divide(ByVal v As Long) As Object
            If (v < 0) Then
                Return MyBase.Divide(v)
            End If
            Return ([CULng](v) / Me.m_value)
        End Function

        Friend Overrides Function Divide(ByVal v As Single) As Object
            Return (v / CSng(Me.m_value))
        End Function

        Friend Overrides Function Divide(ByVal v As UInt16) As Object
            Return ([CULng](v) / Me.m_value)
        End Function

        Friend Overrides Function Divide(ByVal v As UInt32) As Object
            Return ([CULng](v) / Me.m_value)
        End Function

        Friend Overrides Function Divide(ByVal v As UInt64) As Object
            Return (v / Me.m_value)
        End Function

        Friend Overrides Function Divide(ByVal v As ArithmeticLiteral) As Object
            Return v.Divide(Me.m_value)
        End Function

        Friend Overrides Function Modulus() As Object
            Return Nothing
        End Function

        Friend Overrides Function Modulus(ByVal v As Decimal) As Object
            Return Decimal.op_Modulus(v, Me.m_value)
        End Function

        Friend Overrides Function Modulus(ByVal v As Double) As Object
            Return (v Mod CDbl(Me.m_value))
        End Function

        Friend Overrides Function Modulus(ByVal v As Integer) As Object
            If (v < 0) Then
                Return MyBase.Modulus(v)
            End If
            Return (CLng(v) Mod Me.m_value)
        End Function

        Friend Overrides Function Modulus(ByVal v As Long) As Object
            If (v < 0) Then
                Return MyBase.Modulus(v)
            End If
            Return ([CULng](v) Mod Me.m_value)
        End Function

        Friend Overrides Function Modulus(ByVal v As Single) As Object
            Return (v Mod CSng(Me.m_value))
        End Function

        Friend Overrides Function Modulus(ByVal v As UInt16) As Object
            Return ([CULng](v) Mod Me.m_value)
        End Function

        Friend Overrides Function Modulus(ByVal v As UInt32) As Object
            Return ([CULng](v) Mod Me.m_value)
        End Function

        Friend Overrides Function Modulus(ByVal v As UInt64) As Object
            Return (v Mod Me.m_value)
        End Function

        Friend Overrides Function Modulus(ByVal v As ArithmeticLiteral) As Object
            Return v.Modulus(Me.m_value)
        End Function

        Friend Overrides Function Multiply() As Object
            Return Nothing
        End Function

        Friend Overrides Function Multiply(ByVal v As Decimal) As Object
            Return (v * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As Double) As Object
            Return (v * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As Integer) As Object
            If (v < 0) Then
                Return MyBase.Multiply(v)
            End If
            Return (v * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As Long) As Object
            If (v < 0) Then
                Return MyBase.Multiply(v)
            End If
            Return ([CULng](v) * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As Single) As Object
            Return (v * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As UInt16) As Object
            Return (v * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As UInt32) As Object
            Return (v * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As UInt64) As Object
            Return (v * Me.m_value)
        End Function

        Friend Overrides Function Multiply(ByVal v As ArithmeticLiteral) As Object
            Return v.Multiply(Me.m_value)
        End Function

        Friend Overrides Function Subtract() As Object
            Return Nothing
        End Function

        Friend Overrides Function Subtract(ByVal v As Decimal) As Object
            Return (v - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As Double) As Object
            Return (v - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As Integer) As Object
            If (v < 0) Then
                Return MyBase.Subtract(v)
            End If
            Return (v - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As Long) As Object
            If (v < 0) Then
                Return MyBase.Subtract(v)
            End If
            Return ([CULng](v) - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As Single) As Object
            Return (v - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As UInt16) As Object
            Return (v - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As UInt32) As Object
            Return (v - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As UInt64) As Object
            Return (v - Me.m_value)
        End Function

        Friend Overrides Function Subtract(ByVal v As ArithmeticLiteral) As Object
            Return v.Subtract(Me.m_value)
        End Function


        ' Properties
        Friend Overrides ReadOnly Property Value As Object
            Get
                Return Me.m_value
            End Get
        End Property


        ' Fields
        Private m_value As UInt64
    End Class
End Namespace

